<template>
	<div class="" style="width: 100%;">
		<head-top></head-top>


	
		<div class="table_container" :style="'width: 90%;  overflow: hidden;  height:'+(winHeight/1.2)+'px;'">
			<div style="margin: 5px; display: flex;">
				
				
				<span style="font-size: 20px;width: 100px;">账户表 :  </span>
				<div>
					<el-button size="mini" type="success" @click="get_exchange_arrange()">刷新</el-button>
					
					<el-button size="mini" type="primary" @click="exportCSV()">导出</el-button>
				</div>

				<span style="font-size: medium; padding: 10px;">产品:</span>
				<el-select v-model="product_choice" size="small" clearable filterable placeholder="请选择"
					@change="get_exchange_arrange()">
					<el-option v-for="item in product_options" :key="item.label" :label="item.label"
						:value="item.value">
					</el-option>
				</el-select>
				
				<span style="font-size: medium; padding: 10px;">券商:</span>
				<el-select v-model="brokerage_choice" size="small" clearable filterable placeholder="请选择"
					@change="get_exchange_arrange()">
					<el-option v-for="item in brokerage_options" :key="item.label" :label="item.label"
						:value="item.value">
					</el-option>
				</el-select>
				
				
				<span style="font-size: medium; padding: 10px;">日期:</span>
				<el-select v-model="date_choice" size="small" clearable filterable placeholder="请选择">
					<el-option v-for="item in date_options" :key="item.label" :label="item.label" :value="item.value">
					</el-option>
				</el-select>
				
				<div  style="padding-left:20px ;">
					<el-button size="mini" type="warning" @click="addnew_account()">新增</el-button>
					
				</div>
				<span style="font-size: 20px; padding-left: 150px;">选中总金额:{{(strategy_total_asset/10000).toFixed(1)}} 万 :  </span> 
				<span style="padding-left:30px;">只看使用中:</span>
				<el-switch style="margin-left: 30px;height: 30px; "
				  v-model="in_use_flag"
				  active-color="#13ce66"
				  inactive-color="#ff4949">
				</el-switch>
				
				<span style="padding-left:30px;">查询市值:</span>
				<el-switch style="margin-left: 30px;height: 30px; "
				  v-model="qry_flag"
				  active-color="#13ce66"
				  inactive-color="#ff4949">
				</el-switch>
			</div>

			<el-table ref="singleTable" :data="arrange_data" height="100%" border size='small' :fit='true' 
				:style="'width:'+(screenWidth*1.0)+'px;'" :row-class-name=" tableRowClassNamemoneyout"  @selection-change="handleSelectionChange">
		     	<el-table-column   type="selection" label="ID"  width="60"></el-table-column>
				<el-table-column   type="index" label="index"  width="60"></el-table-column>
				
				<el-table-column prop="product_name" label="产品名"  sortable  align></el-table-column>
				<el-table-column prop="prod_code" label="prod_code"   align></el-table-column>
				<el-table-column prop="account" label="account"   align></el-table-column>
				
				<el-table-column prop="program_code" label="program_code"  sortable  align></el-table-column>
<!-- 				<el-table-column prop="product_nick_name" label="产品昵称"    align></el-table-column>
 -->				<!-- <el-table-column prop="product_order" label="产品次序"  sortable  align></el-table-column> -->
				<!-- <el-table-column prop="begin_date_kk" label="开始时间"    align></el-table-column> -->
				<!-- <el-table-column prop="manger" label="管理人"    align></el-table-column> -->
				<!-- <el-table-column prop="begin_value" label="初始净值"    align></el-table-column> -->
				<!-- <el-table-column prop="product_category" label="系列名称"  sortable  align></el-table-column> -->
<!-- 				<el-table-column prop="product_strategy" label="对标指数"  sortable  align></el-table-column>
 -->				<!-- <el-table-column prop="read_fund_class" label="净值类别"  sortable  align></el-table-column> -->
				<el-table-column prop="account_type" label="账户类型"  sortable  align></el-table-column>
				<el-table-column prop="product_strategy" label="账户策略"  sortable  align></el-table-column>
				<el-table-column prop="use_flag" label="使用中"   sortable  align></el-table-column>
				
				
				
				
				<el-table-column prop="total_asset" label="最新资产" sortable width="120">
					
					<template slot-scope="scope"><span  style="color:dodgerblue;"> {{(scope.row['total_asset']/10000).toFixed(2) }}万 </span> </template>
				</el-table-column>
				<el-table-column prop="total_asset" label="资产占比" sortable width="120">
					
					<template slot-scope="scope">
						<span :style="{ color: (scope.row['total_asset'] / strategy_total_asset > 1) ? 'inherit' : 'red' }">  
							{{ (scope.row['total_asset'] / strategy_total_asset > 1) ? '0' : ((scope.row['total_asset'] / strategy_total_asset*100).toFixed(2)) + '%' }}  
						</span>			
					</template>
				</el-table-column>
				
				
				<el-table-column prop="account_brokerage" label="券商"  sortable  align></el-table-column>
				<el-table-column prop="account_brokerage_total" label="券商完整"   align></el-table-column>
				<el-table-column prop="auto_flag" label="程序交易"   align></el-table-column>
				<!-- <el-table-column prop="product_trusteeship" label="托管平台"   align></el-table-column> -->
				<el-table-column prop="margin_flag" label="margin_flag"   align></el-table-column>
				<el-table-column prop="usable_margin_flag" label="usable_margin_flag"   align></el-table-column>
				<el-table-column prop="account_num" label="账户号"   align></el-table-column>
				<el-table-column prop="login_pwd" label="login_pwd"   align></el-table-column>
				<el-table-column prop="transact_pwd" label="transact_pwd"   align></el-table-column>
				
				<el-table-column label="操作" :width='90'>
					<template slot-scope="scope">
						<el-button size="mini" type="primary" @click="handlefixaccount(scope.$index, scope.row,'binary')">修改
						</el-button>
						<!-- <el-button size="small" type="warning" @click="change_configindex(scope.$index, scope.row)">详情</el-button> -->
					</template>
				</el-table-column>
		
			</el-table>

		</div>
		<el-dialog :visible.sync="visible2">
			<div style="display: flex;flex-flow: column; justify-content:center;">
				<div style="display: flex; justify-content:center;">
					<span style="color: orange;font-size: 24px; font-family: KaiTi, Helvetica, sans-serif;">修改账户 {{fix_account['program_code']}}</span>
				</div>
				<div style="display: flex;flex-flow:row; ">
					<div style="width: 100%; height: 600px;overflow-y: scroll;">
					
						
						<div style="display: flex;align-items: center;center;padding-top: 20px; justify-content:center;">
							<span style="width: 20%;">产品列表：</span>
							<el-select v-model="fix_account['product_name']" filterable size="small" style="width: 70%;" collapse-tags placeholder="请选择">
								<el-option v-for="item in product_options" :key="item.value" :label="item.label"
									:value="item.value">
								</el-option>
							</el-select>
						</div>
						<div style="display: flex;align-items: center;center;padding-top: 20px; justify-content:center;">
							<span style="width: 20%;">prod_code：</span>
							<el-input v-model="fix_account['prod_code']"  size="small" style="width: 70%;"placeholder="prod_code"></el-input>
						</div>
					
						
						<div style="display: flex;align-items: center;center;padding-top: 20px; justify-content:center;">
							<span style="width: 20%;">账户策略：</span>
							<el-select v-model="fix_account['product_strategy']" size="small" style="width: 70%;" collapse-tags placeholder="请选择">
								<el-option v-for="item in strategy_options" :key="item.value" :label="item.label"
									:value="item.value">
								</el-option>
							</el-select>
						</div>
						<div style="display: flex;align-items: center;center;padding-top: 20px; justify-content:center;">
							<span style="width: 20%;">account：</span>
							<el-input v-model="fix_account['account']"   size="small" style="width: 70%;"placeholder="account"></el-input>
						</div>
						
						<div style="display: flex;align-items: center;center;padding-top: 20px; justify-content:center;">
							<span style="width: 20%;">account_num：</span>
							<el-input v-model="fix_account['account_num']"  size="small" style="width: 70%;"placeholder="account_num"></el-input>
						</div>
						
						<div style="display: flex;align-items: center;center;padding-top: 20px; justify-content:center;">
							<span style="width: 20%;">账户类型：</span>
							<el-select v-model="fix_account['account_type']" size="small" style="width: 70%;" collapse-tags placeholder="请选择">
								<el-option v-for="item in type_options" :key="item.value" :label="item.label"
									:value="item.value">
								</el-option>
							</el-select>
						</div>
					
					
						<div style="display: flex;align-items: center;center;padding-top: 20px; justify-content:center;">
							<span style="width: 20%;">使用情况：</span>
							<el-select v-model="fix_account['use_flag']"  size="small" style="width: 70%;" collapse-tags placeholder="请选择">
								<el-option v-for="item in use_options" :key="item.value" :label="item.label"
									:value="item.value">
								</el-option>
							</el-select>
						</div>
						
						<div style="display: flex;align-items: center;center;padding-top: 20px; justify-content:center;">
							<span style="width: 20%;">券商简称：</span>
							<el-input v-model="fix_account['account_brokerage']" size="small" style="width: 70%;"placeholder="account_brokerage"></el-input>
						</div>
						
						<div style="display: flex;align-items: center;center;padding-top: 20px; justify-content:center;">
							<span style="width: 20%;">券商完整：</span>
							<el-input v-model="fix_account['account_brokerage_total']" size="small" style="width: 70%;"placeholder="account_brokerage_total"></el-input>
						</div>
						<div style="display: flex;align-items: center;center;padding-top: 20px; justify-content:center;">
							<span style="width: 20%;">程序交易：</span>
							<el-input v-model="fix_account['auto_flag']" size="small" style="width: 70%;"placeholder="auto_flag"></el-input>
						</div>
						<!-- <div style="display: flex;align-items: center;center;padding-top: 20px; justify-content:center;">
							<span style="width: 20%;">托管平台：</span>
							<el-input v-model="fix_account['product_trusteeship']" size="small" style="width: 70%;"placeholder="product_trusteeship"></el-input>
						</div> -->
						<div style="display: flex;align-items: center;center;padding-top: 20px; justify-content:center;">
							<span style="width: 20%;">margin：</span>
							<el-input v-model="fix_account['margin_flag']" size="small" style="width: 70%;"placeholder="margin_flag"></el-input>
						</div>
						<div style="display: flex;align-items: center;center;padding-top: 20px; justify-content:center;">
							<span style="width: 20%;">usable_margin：</span>
							<el-input v-model="fix_account['usable_margin_flag']" size="small" style="width: 70%;"placeholder="usable_margin_flag"></el-input>
						</div>
						<div style="display: flex;align-items: center;center;padding-top: 20px; justify-content:center;">
							<span style="width: 20%;">login_pwd：</span>
							<el-input v-model="fix_account['login_pwd']" size="small" style="width: 70%;"placeholder="login_pwd"></el-input>
						</div>
						<div style="display: flex;align-items: center;center;padding-top: 20px; justify-content:center;">
							<span style="width: 20%;">transact_pwd：</span>
							<el-input v-model="fix_account['transact_pwd']" size="small" style="width: 70%;"placeholder="transact_pwd"></el-input>
						</div>
						
					
					</div>
					
				</div>
				<div style="display: flex;align-items: center;padding-top: 20px;  justify-content:center">
					<el-button style=" height: 33px;" size="small" type="success" @click="changedata_account()">修改确认</el-button>
				</div>
		
		  
			</div>
		
		
		</el-dialog>
	</div>
</template>

<script>
	import headTop from '@/components/headTop'
	export default {
		data() {
			return {
				qry_flag:false,
				in_use_flag:true,
				checkflag: false,
				core_pos: [],
				pos_index_item: '',
				product_choice: "",
				product_options: [],
				brokerage_choice: "",
				brokerage_options: [],
				
				target_pos_index_options: [],
				date_choice: "",
				date_options: [],
				tableData: [],
				currentRow: null,
				inoutflag:false,
				count: 0,
				exchange_detail: [],
				LP_account_list: [],
				fix_account: {},
				visible: false,
				visible2: false,
				screenWidth: document.body.clientWidth, // 屏幕尺寸
				screenHeight: document.body.clientHeight, // 屏幕尺寸
				moneyindex: "0",
				arrange_data: [],
				strategy_total_asset:1,
				
				
				
				
				category_options: [
					{
						value: '聚核系列',
						label: '聚核系列'
					},
					{
						value: '沪深300',
						label: '沪深300'
					},
					{
						value: '中证500',
						label: '中证500'
					},
					{
						value: 'CTA系列',
						label: 'CTA系列'
					},
					{
						value: '中证1000',
						label: '中证1000'
					},
					{
						value: '国证1000',
						label: '国证1000'
					},
					{
						value: '对冲系列',
						label: '对冲系列'
					},
					{
						value: '国证2000',
						label: '国证2000'
					},

				],
				
				
				
				strategy_options: [
					{
						value: 'bond',
						label: 'bond'
					},
					{
						value: 'mix_alphaT',
						label: 'mix_alphaT'
					},
					{
						value: '300alphaT',
						label: '300alphaT'
					},
					{
						value: 'a500alphaT',
						label: 'a500alphaT'
					},
					{
						value: '500alphaT',
						label: '500alphaT'
					},
					{
						value: '3000alphaT',
						label: '3000alphaT'
					},
					{
						value: '1000alphaT',
						label: '1000alphaT'
					},
					{
						value: '2000alphaT',
						label: '2000alphaT'
					},
					{
						value: 'gz1000alphaT',
						label: 'gz1000alphaT'
					},
					{
						value: 'gz2000alphaT',
						label: 'gz2000alphaT'
					},
					{
						value: '1000',
						label: '1000'
					},
					{
						value: '2000',
						label: '2000'
					},
					{
						value: '3000',
						label: '3000'
					},
					{
						value: 'gz1000',
						label: 'gz1000'
					},
					{
						value: 'gz2000',
						label: 'gz2000'
					},
					
					{
						value: 'future_commodity',
						label: 'future_commodity'
					},
					{
						value: 'index_future',
						label: 'index_future'
					},
					
					{
						value: 'future_cffex',
						label: 'future_cffex'
					},
					
				],
				
				type_options: [
					{
						value: 'future_cffex',
						label: 'future_cffex'
					},
					
					{
						value: 'index_future',
						label: 'index_future'
					},
					{
						value: 'bond',
						label: 'bond'
					},
					{
						value: 'future_commodity',
						label: 'future_commodity'
					},
					{
						value: 'equities',
						label: 'equities'
					},

				],
				
				use_options: [
					{
						value: 'yes',
						label: 'yes'
					},
					{
						value: 'no',
						label: 'no'
					},

				],

			}
		},
		components: {
			headTop,
		},



		activated() {

			// console.log("当前登入用户", this.$store.state.adminInfo.name);
			//    if (this.tradesysPermission_list.indexOf (this.$store.state.adminInfo.permission) ==-1) {
			// 	console.log(this.$store.state.adminInfo.name,"未登入")
			// 	this.$message({type: 'error',	message: '没有权限',});
			// 	this.$router.push({
			// 		path: `/manage`
			// 	})
			// }
		},
		created() {
			this.get_date_last()
			this.get_exchange_arrange()
			this.get_tradesys_account()
			this.get_brokerage_account()
		},
		computed: {
			
		},

		methods: {
			
			handleSelectionChange(val) {
				this.multipleSelection = val;
				let total_asset=0;
				for(let i=0;i<this.multipleSelection.length;i++){
					// console.log(this.multipleSelection[i].total_asset) 	
					total_asset+= this.multipleSelection[i].total_asset
				}
				this.strategy_total_asset=total_asset
				// console.log(total_asset)
							
			},
			
			handlefixaccount(index, row) {
				console.log("row", row)
				this.fix_account = row
				this.visible2 = true
			},
			get_date_last() {
				var that = this;
				
				
				let sql =
					" select distinct date_format(date,'%Y-%m-%d') as date_str  from `LP_account_day` where date>'20230101' order by date_str desc;"
				that.$axios.post(that.lpapi2, "form=get_data&sql=" + sql).then(response => {
					console.log(response, 'data_tradesys_account');
					if (response.status = 200) {
						that.date_options = []
						that.date_choice=response.data[0]['date_str']
						//for (var i = 0; i < response.data.length; i++) {
						for (var i =0; i <=response.data.length; i++) {
							let char = {
								value: response.data[i]['date_str'],
								label: response.data[i]['date_str'],
							};
							that.date_options.push(char);
						}
					} else {
						console.log(response.data.statusCode);
					}
				})
			
			},
			
			get_tradesys_account() {
				var that = this;
				// console.log(that.lpapi2)
			
				let sql ="select distinct product_name from `config_product`  ORDER BY product_name  ;"
				that.$axios.post(that.lpapi2, "form=get_data&sql=" + sql).then(response => {
			
					console.log(response, 'LP_account_dict')
					let plat_list = []
					if (response.status = 200) {
						that.product_options = []
						for (var i = 0; i < response.data.length; i++) {
							let char = {
								value: response.data[i]['product_name'],
								label: response.data[i]['product_name'],
			
							};
			
							that.product_options.push(char);
						}
			
					} else {
						console.log(response.data.statusCode);
					}
				})
			
			
			},
			get_brokerage_account() {
				var that = this;
				// console.log(that.lpapi2)
			
				let sql ="select distinct account_brokerage_total from `config_account`  ORDER BY account_brokerage_total  desc;"
				that.$axios.post(that.lpapi2, "form=get_data&sql=" + sql).then(response => {
			
					console.log(response, 'LP_account_dict')
					let plat_list = []
					if (response.status = 200) {
						that.brokerage_options = []
						for (var i = 0; i < response.data.length; i++) {
							let char = {
								value: response.data[i]['account_brokerage_total'],
								label: response.data[i]['account_brokerage_total'],
			
							};
			
							that.brokerage_options.push(char);
						}
			
					} else {
						console.log(response.data.statusCode);
					}
				})
			
			
			},
		
	
			exportCSV(){ //导出CSV
			   //生成文件
			   let arr = ['产品名字,账户名,系统名称,账户策略,账户id,账户号,账户类型,券商,总资产'];	//第一行，列名。csv文件会默认根据逗号分割成列
			   let data = this.arrange_data;	//需要导出的列表
			   
			   for(let i=0;i<this.arrange_data.length;i++){
				   let temp = [];
				   temp.push(data[i].product_name)	//每一列
				   temp.push(data[i].account)	//每一列
				   temp.push(data[i].program_code)	//每一列
				   temp.push(data[i].product_strategy)	//每一列
				   temp.push(data[i].account)
				   temp.push(data[i].account_num)
				   temp.push(data[i].account_type)
				    
				   temp.push(data[i].account_brokerage)
				   temp.push(data[i].total_asset)
				   arr.push(temp.join(','));	//添加每一行的内容
			   }
			   console.log(arr)
			   let content = "data:text/csv;charset=utf-8,\ufeff" + arr.join('\n');	//文件格式+文件内容，\n换行
			
			   //下载文件
			   var link = document.createElement("a");
			   link.setAttribute("href", content);
			   link.setAttribute("download", "资产统计.csv");
			   link.click();
			},
	
		
		
		
		
		
		
		
		
		
		
		
		
		
			get_exchange_arrange() {
				var that = this;
				console.log(that.lpapi2)
			    let in_use1=''
				if(this.in_use_flag ){
					 in_use1='yes'
				}
				else{
					 in_use1=''
				}
				
				
				
				let sql = ""
				
				if (this.brokerage_choice != ""  &&  this.qry_flag) {
					sql ="SELECT  pc.*,    pas.total_asset  \
						FROM  (SELECT * from view_config_account    where account_brokerage_total='" + this.brokerage_choice +"' ) pc\
						LEFT JOIN (   SELECT    total_asset,account FROM   LP_account_trade_qry  \
						WHERE    (account, datetime) IN (   SELECT    account,     MAX(datetime)  \
						FROM   LP_account_trade_qry   where total_asset>0 and date >= '"+this.date_choice+"' - INTERVAL 12 DAY  \
						 and date<= '"+this.date_choice+"'   and flag!='tuoguan' GROUP BY   account  )  \
						) pas ON pc.qry_account = pas.account  where pc.use_flag like '%"+in_use1+"%'  ;"
				} 
				else if (this.brokerage_choice != ""  &&  !this.qry_flag) {
					sql ="SELECT * from view_config_account   where account_brokerage_total='" + this.brokerage_choice +"'  and  \
					 use_flag like '%"+in_use1+"%'   ;"
				} 
							
				
					
				else if (this.product_choice == ""  &&  this.qry_flag) {
					sql = " SELECT  pc.*,    pas.total_asset  FROM  view_config_account pc  \
					LEFT JOIN (   SELECT    total_asset,account FROM   LP_account_trade_qry  \
					WHERE    (account, datetime) IN (   SELECT    account,     MAX(datetime)  FROM   LP_account_trade_qry  \
					 where total_asset>0  and date >= '"+this.date_choice+"' - INTERVAL 12 DAY  and date<= '"+this.date_choice+"'  and flag!='tuoguan' GROUP BY   account  )  \
					) pas ON pc.qry_account = pas.account where pc.use_flag  like '%"+in_use1+"%'   order by product_name	;"
				} 
						
				else if (this.product_choice != ""  &&  this.qry_flag) {
					sql ="SELECT  pc.*,    pas.total_asset  \
						FROM  (SELECT * from view_config_account    where product_name='" + this.product_choice +"' ) pc\
						LEFT JOIN (   SELECT    total_asset,account FROM   LP_account_trade_qry  \
						WHERE    (account, datetime) IN (   SELECT    account,     MAX(datetime)  \
						FROM   LP_account_trade_qry   where total_asset>0 and date >= '"+this.date_choice+"' - INTERVAL 12 DAY  \
						 and date<= '"+this.date_choice+"'   and flag!='tuoguan' GROUP BY   account  )  \
						) pas ON pc.qry_account = pas.account  where pc.use_flag like '%"+in_use1+"%'  ;"
				} 
			
				else if (this.product_choice == ""  &&  !this.qry_flag) {
					sql = " SELECT  pc.*  FROM  view_config_account pc   where pc.use_flag  like '%"+in_use1+"%'   order by product_name	;"
				} 
						
				else if (this.product_choice != ""  &&  !this.qry_flag) {
					sql ="SELECT * from view_config_account   where product_name='" + this.product_choice +"'  and  \
					 use_flag like '%"+in_use1+"%'   ;"
				} 
			
			
			
			
				that.arrange_data = []
				that.$axios.post(that.lpapi2, "form=get_data&sql=" + sql).then(response => {

					console.log(response.data[0], 'config_account')

					if (response.status = 200) {
						if (response.data[0].hasOwnProperty('message')) {
							that.arrange_data = []
						} else {
							that.arrange_data = response.data;
						}
						// that.arrange_data = response.data;
					} else {
						console.log(response.data.statusCode);
					}
				})


			},


			changedata_account(){
				var that = this
				if (this.allow_readpw!='yes' ){
					this.$prompt('请输入密码', '提示', {
						confirmButtonText: '确定',
						cancelButtonText: '取消',
						inputType: 'password',
					}).then(({
						value
					}) => {
						if (value == '621890') {
							this.$message({
								type: 'success',
								message: '密码正确:'
							});
							that.allow_readpw='yes'
						} else {
							this.$message({
								type: 'error',
								message: '密码出错'
							});
						}
					}).catch(() => {
						this.$message({
							type: 'info',
							message: '取消输入'
						});
					});
					return
				}
				
				that.$confirm('此操作将永久修改数据, 是否继续?', '提示', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',inputType: 'password',
					type: 'warning'
				}).then(() => {
					let fixdata=that.fix_account
			
					
					
					let sql3 = "UPDATE `config_account` SET \
						`product_name` = '" + fixdata['product_name'] + "', \
						`product_strategy` = '" + fixdata['product_strategy'] + "',  \
						`account_type` = '" + fixdata['account_type'] + "',  \
						`account_num` = '" + fixdata['account_num'] + "',  \
						`account` = '" + fixdata['account'] + "',  \
						`prod_code` = '" + fixdata['prod_code'] + "',  \
						`use_flag` = '" + fixdata['use_flag'] + "',  \
						`account_brokerage` = '" + fixdata['account_brokerage'] + "',  \
						`margin_flag` = '" + fixdata['margin_flag'] + "',  \
						`usable_margin_flag` = '" + fixdata['usable_margin_flag'] + "',  \
						`login_pwd` = '" + fixdata['login_pwd'] + "',  \
						`transact_pwd` = '" + fixdata['transact_pwd'] + "',  \
						`auto_flag` = '" + fixdata['auto_flag'] + "',  \
						`account_brokerage_total` = '" + fixdata['account_brokerage_total'] + "'  \
						WHERE `program_code` = '" + fixdata['program_code'] + "' ;"
					
					// var jsonStr = JSON.stringify(fixdata);
					that.$axios.post(that.lpapi2, "form=do_sql&sql=" + sql3).then(response => {
					// that.$axios.post(that.lpapi2, "form=do_sql&table=LP_account_list&updata="+ jsonStr).then(response => {
						if (response.status = 200) {
							that.$message({
								type: 'success',
								message: '修改成功!',
							});
							that.visible2 = false;
							that.get_tradesys_account();
							that.$forceUpdate();
						} else {
							that.visible2 = false;
							that.$message({
								showClose: true,
								message: response.data,
								duration: 4000,
								type: 'error'
							});
						}
					})
				
				}).catch(() => {
					that.$message({
						type: 'info',
						message: '已取消修改'
					});
				});
				
				
				
				
			},

			addnew_account() {
				var that = this
				var new_account=''
				if (this.allow_readpw!='yes' ){
					this.$prompt('请输入密码', '提示', {
						confirmButtonText: '确定',
						cancelButtonText: '取消',
						inputType: 'password',
					}).then(({
						value
					}) => {
						if (value == '621890') {
							this.$message({
								type: 'success',
								message: '密码正确:'
							});
							that.allow_readpw='yes'
						} else {
							this.$message({
								type: 'error',
								message: '密码出错'
							});
						}
					}).catch(() => {
						this.$message({
							type: 'info',
							message: '取消输入'
						});
					});
					return
				}
				
				if (that.product_choice == '') {
					this.$message({
						type: 'error',
						message: '必须选择产品'
					});
					return
				}
			
			    var new_account=''
				this.$prompt('请输入program_code (期货输入账户号)', '提示', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					inputType: 'text',
				}).then(({
					value
				}) => {
					new_account=value
					this.in_use_flag=false
					
					// let sql2 = "REPLACE INTO `LP_product_dict`  (`product_name`,`product_nick_name`,`product_order`,`product_category`,`begin_date`,`begin_value`,`read_fund_class`,`product_strategy`,`in_use`,`account`) \
					// VALUES ('" + this.arrange_data[0]['product_name'] + "','" + this.arrange_data[0]['product_nick_name'] + "','" + this.arrange_data[0]['product_order'] + "','" +
					// 	this.arrange_data[0]['product_category']  + "','" + this.arrange_data[0]['begin_date_kk']  + "','" + this.arrange_data[0]['begin_value']  
					// 	+ "','" + this.arrange_data[0]['read_fund_class']  + "','" + this.arrange_data[0]['product_strategy']  
					// 	+ "','no','new'   );"
					let sql2 = "REPLACE INTO `config_account`  (`product_name`,`program_code`,`account`,`account_num`,`use_flag`,`product_strategy`,`account_type`) \
					VALUES ('" + this.product_choice + "','"+new_account+"','"+new_account+"','"+new_account+"','no','index_future','index_future'  );"
					that.$axios.post(that.lpapi2, "form=do_sql&sql=" + sql2).then(response => {
						console.log(response, 'do_sql');
						if (response.status = 200) {
							that.$message({
								message: '新增完成',
								type: 'success'
							});
							
							that.get_tradesys_account();
							that.get_exchange_arrange();
							that.$forceUpdate();
						} else {
							this.$message({
								message: '新增失败',
								type: 'error'
							});
							console.log(response.data);
						}
					})	
				}).catch(() => {
					this.$message({
						type: 'info',
						message: '取消输入'
					});
				});
				
				
			
				


			},

			
			tableRowClassNamemoneyout({
				row,
				rowIndex
			}) {
		
				if (this.arrange_data[rowIndex]['status'] == '待处理' | this.arrange_data[rowIndex]['status'] == '准备' ) {
					return 'bacorange';
				}
				if (this.arrange_data[rowIndex]['status'] == '异常') {
					return 'bacOrangeRed';
				}
				return '';
			}

		},
	}
</script>

<style>
	.el-table .bacOrangeRed {
		background: OrangeRed;
	}

	.el-table .bacorange {
		background: orange;
	}

	.el-table .success-row {
		background: grey;
		color: white;
	}

	.table_container {
		margin: 20px 5%;
		/* background-color: #0000FF; */
	}

	.el-table .grey {
		background: Silver;
	}

	.el-table .DarkGray {
		background: DarkGray;
	}

	.el-table .LightCoral {
		background: LightCoral;
		color: white;
	}

	.el-table .LimeGreen {
		background: LimeGreen;
	}

	.el-table .green {
		background: green;
	}

	.el-table .LightSlateGray {
		background: LightSlateGray;
	}

	.el-table .red {
		background: red;
		color: white;
	}

	.el-table .orange {
		background: NavajoWhite;
		color: black;
	}

	.el-table .blue {
		background: blue;
	}

	.el-table .purple {
		background: Violet;
		color: black;
	}

	.el-table .LightSteelBlue {
		background: LightSteelBlue;
	}

	.el-table .Goldenrod {
		background: Goldenrod;
	}

	.el-table .xingmu {
		background: Goldenrod;
		color: red;
		font-weight: bold;

	}


	.el-table .black {
		background: black;
		color: white;
	}

	.el-table .green {
		background: green;
		color: white;
	}

	.el-table .CornflowerBlue {
		background: CornflowerBlue;
		color: white;
	}

	.el-table .DodgerBlue {
		background: DodgerBlue;
	}
</style>
